package classes.command.dynamiccalendar.form
{
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.commands.ICommand;
	import classes.event.dynamiccalendar.form.DynamicCalendarEventFormSaveClickedEvent;
	import classes.model.CoreModelLocator;
	import classes.model.DataHolder;
	
	public class DynamicCalendarEventFormSaveClickedCommand implements ICommand
	{
		private static var _model:CoreModelLocator = CoreModelLocator.getInstance();
		/**
		 * Constructor
		 */
	  	public function DynamicCalendarEventFormSaveClickedCommand() : void {
		
		}//end constructor
		
		/**
		 * The main function assocaited wtih this command
		 * 
		 * @param	event	The source event
		 */ 
		public function execute( event : CairngormEvent ) : void
		{
			if(event is DynamicCalendarEventFormSaveClickedEvent){
				trace("event");
				var obj:Object = new Object();
				obj.date = _model.dCalEventForm.currentDate;
				obj.hour = _model.dCalEventForm.cmbHours.selectedItem.data;
				obj.meridiem = _model.dCalEventForm.cmbMeridiem.selectedItem.data;
				obj.mins = _model.dCalEventForm.cmbMins.selectedItem.data;
				obj.desc = _model.dCalEventForm.txtDescription.text;
				DataHolder.getInstance().addEvent(obj);
				_model.dCalEventForm.visible = false;
				//TODO
			}//end if
			
		}//end execute (function)
		
		
		
		
		
	}//end class
}//end package

